package com.itheima.app.service.Impl;

import com.itheima.app.mapper.SetMealMapper;
import com.itheima.app.service.SetMealService;
import com.itheima.health.model.common.R;
import com.itheima.health.model.pojos.CheckGroup;
import com.itheima.health.model.pojos.Setmeal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.websocket.server.ServerEndpoint;
import java.util.List;

@Service
public class SetMealServiceImpl implements SetMealService {
    @Autowired
    private SetMealMapper setMealMapper;
    @Override
    public Setmeal selectById(Long id) {
        Setmeal setmeal=setMealMapper.selectById(id);
        List<CheckGroup> checkGroups = setMealMapper.selectBySetMealId(id);
        setmeal.setCheckGroups(checkGroups);
        return setmeal;
    }

    @Override
    public R showSetmealList() {
        List<Setmeal> setmeals = setMealMapper.selectList(null);
        return R.success(setmeals);
    }
}
